//
//  TabBarViewController.m
//  BoYue
//
//  Created by drouce on 15/11/20.
//  Copyright © 2015年 drouce. All rights reserved.
//

#import "TabBarViewController.h"
#import "TuWanViewController.h"
#import "ReaderViewController.h"
#import "AuditionVideoViewController.h"
#import "AppDelegate.h"
#import "MyController.h"

@interface TabBarViewController ()<UITabBarControllerDelegate,UITabBarDelegate>
@property (nonatomic) NSUInteger latestSelectIndex;
@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.tabBar.translucent = NO;
    UINavigationController *tuWanVC = [TuWanViewController standardTuWanNavi];
    UINavigationController *videoVC = [AuditionVideoViewController  sharedStance];
    
    UINavigationController *readVC = [ReaderViewController sharedStance];
    
    UINavigationController *myVC = [MyController defaultMyNavi];
    
    
    [self addItem:tuWanVC title:@"资讯" imageName:@"tabbar_icon_news_normal" selectedImage:@"tabbar_icon_news_highlight"];
    [self addItem:videoVC title:@"视听" imageName:@"tabbar_icon_media_normal" selectedImage:@"tabbar_icon_media_highlight"];
    [self addItem:readVC title:@"阅读" imageName:@"tabbar_icon_reader_normal" selectedImage:@"tabbar_icon_reader_highlight"];
    [self addItem:myVC title:@"个人" imageName:@"tabbar_icon_me_normal" selectedImage:@"tabbar_icon_me_highlight"];
    NSArray *array = @[tuWanVC,videoVC,readVC,myVC];
    self.viewControllers = array;
    
}
- (void)addItem:(UIViewController *)vc title:(NSString *)title imageName:(NSString *)imageName selectedImage:(NSString *)selectedImageName{
    
        vc.title = title;
    
    // 正常状态下照片
    vc.tabBarItem.image = [self imageAlwaysOriginal:imageName];
    
    // 选择时照片
    vc.tabBarItem.selectedImage = [self imageAlwaysOriginal:selectedImageName];
    
    
    //[self addChildViewController:vc];
}


#pragma mark - 取消图片渲染
- (UIImage *)imageAlwaysOriginal:(NSString *)imageName{
    // 正常状态下照片
    UIImage *image = [UIImage imageNamed:imageName];
    if ([[UIDevice currentDevice].systemVersion doubleValue]>7.0) {
        // 声明这张图片用原图
        image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    }
    return image;
}


@end
